﻿using System;
using System.IO;
using System.Threading.Tasks;
using Microsoft.Extensions.Configuration;
using Newtonsoft.Json;
using OS.Common.Core;
using OS.Common.Plugs.ConfigPlug;
using OS.Common.Utils;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory())
                .AddJsonFile("appsettings.json", false, true);

            IConfigurationRoot configuration = builder.Build();

            ConfigurationUtil.Configuration = configuration;

            //为接口注册其实现类
            IocContainer<IConfigPlug>.Set<ConfigurationUtil>();
            IocContainer<IPcSpiderRepository>.Set<PcSpiderRepository>();

            PCSpiderService service = new PCSpiderService();
            var result = Task.Run(() => service.GetList(1)).GetAwaiter().GetResult();
            Console.WriteLine("Hello World! " + JsonConvert.SerializeObject(result));
        }

        public async Task<PageListResult<pc_spider>> GetCurrent(int status)
        {
            PCSpiderService service = new PCSpiderService();
            return await service.GetList(status);
        }
    }
}
